package com.paf.android;

import com.paf.android.display.Console;
import com.paf.android.display.CustomToolbar;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.InputType;
import android.view.ViewGroup.LayoutParams;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SWFCompilerActivity extends Activity {
	
	Console console;
	EditText codeView;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        EditLayout();
        KeepGoing();
    }
    
    private void EditLayout(){
    	//Add Toolbar
    	LinearLayout layout = (LinearLayout) findViewById(R.id.main_container);
    	CustomToolbar toolbar = new CustomToolbar(this, 0);
    	layout.addView(toolbar, 0);    	
    	
    	//Add TreeView (fake)
    	LinearLayout sideContainer = (LinearLayout) findViewById(R.id.side_container);
    	TextView treeView = new TextView(this);
    	treeView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 560));
    	treeView.setText(R.string.tree_view);
    	sideContainer.addView(treeView);
    	
    	//Add Console View
    	this.console = new Console(this, sideContainer);
    	
    	//Add Code View
    	LinearLayout appContainer = (LinearLayout) findViewById(R.id.app_container);
    	codeView = new EditText(this);
    	codeView.setId(307);
    	codeView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    	codeView.setGravity(android.view.Gravity.TOP);
    	codeView.setTextColor(Color.BLUE);    	
    	codeView.setEms(10);
    	codeView.setBackgroundColor(Color.WHITE);
    	codeView.setHorizontallyScrolling(false);
    	codeView.setTextIsSelectable(true);
    	codeView.setMaxLines(10);
    	codeView.setInputType(codeView.getInputType() | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    	codeView.setText(R.string.default_class);
    	appContainer.addView(codeView);
    	codeView.requestFocus();
    	toolbar.codeView = codeView;
    }

	private void KeepGoing(){
    	//this.console.setText("first line\n"+"second line\n"+"third line");
    	this.console.error("this is an error"+'\n');
    	this.console.error("this is an error"+'\n');
    	//this.console.system("this is an system message\\n");
    	//this.console.log("this is a log");
    }
}